package org.example.flea_market_mvc.entity;

import java.util.List;

/**
 * 分页查询结果封装类
 * @param <T> 数据类型
 */
public class PageInfo<T> {
    private int pageNum;     // 当前页码
    private int pageSize;    // 每页数量
    private int total;       // 总记录数
    private int pages;       // 总页数
    private List<T> list;    // 当前页数据列表

    // 构造方法
    public PageInfo(int pageNum, int pageSize, int total, List<T> list) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.pages = (int) Math.ceil((double) total / pageSize);
        this.list = list;
    }

    // Getters and Setters
    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}